# macros

# The OBJPATH specifies path to temporary data files.
OBJPATH = obj

# The OUTPATH specifies output path to resulting executable image.
OUTPATH = x86

OBJLIST = rpcstub.obj      \
          webcore_c.obj    \
          datacore_c.obj   \
          RpcClient.obj    \
          RpcWebClient.obj \
          RpcDcClient.obj  \
          dllmain.obj

# The OBJPATHLIST specifies list of paths to object files.
OBJPATHLIST = \
          ./$(OBJPATH)/rpcstub.obj      \
          ./$(OBJPATH)/webcore_c.obj    \
          ./$(OBJPATH)/datacore_c.obj   \
          ./$(OBJPATH)/RpcClient.obj    \
          ./$(OBJPATH)/RpcWebClient.obj \
          ./$(OBJPATH)/RpcDcClient.obj  \
          ./$(OBJPATH)/dllmain.obj

# The LIBS specifies list of additional LIB files used by linker.
LIBS    = "kernel32.lib"   \
          "user32.lib"     \
          "gdi32.lib"      \
          "comdlg32.lib"   \
          "advapi32.lib"   \
          "shell32.lib"    \
          "ole32.lib"      \
          "oleaut32.lib"   \
          "uuid.lib"

# The all specifies high level target.
all: mkdirs bwconn.dll

# The mkdirs specifies the 1st sub-target within the 'all' target.
mkdirs:
    mkdir $(OBJPATH)
    mkdir $(OUTPATH)

# These targets specify rules of compilation of 'IDL' files.
datacore_h.h datacore_c.c: 
    midl /env win32 /h "datacore_h.h" /W1 /char signed /nologo datacore.idl
    
webcore_h.h webcore_c.c: 
    midl /env win32 /h "webcore_h.h" /W1 /char signed /nologo webcore.idl

# Target specifies rule of compilation of 'C' files.
{}.c{}.obj:
    cl /c /EHsc /Fo./$(OBJPATH)/ $<

# Target specifies rule of compilation of 'CPP' files.    
{}.cpp{}.obj:
    cl /c /EHsc /Fo./$(OBJPATH)/ $<
    
# The bwconn.dll specifies 2nd sub-target within the 'all' target.
bwconn.dll: $(OBJLIST)
    link /SUBSYSTEM:WINDOWS /NXCOMPAT /DYNAMICBASE $(LIBS) /DEF:"export.def"   \
         /DLL /IMPLIB:"./$(OBJPATH)/bwconn.lib" $(OBJPATHLIST)                 \
         /LIBPATH:"$(VCInstallDir)lib" /OUT:./$(OUTPATH)/bwconn.dll 
   
# Targets specify dependencies of OBJ files.
rcpstub.obj:      rpcstub.cpp
webcore_c.obj:    webcore_c.c
datacore_c.obj:   datacore_c.c
RpcClient.obj:    RpcClient.cpp
RpcWebClient.obj: RpcWebClient.cpp
RpcDcClient.obj:  RpcDcClient.cpp
dllmain.obj:      dllmain.cpp